home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / Developer Essentials Jul 90 / Apple II / Programming & Utilities / Apple IIgs APW Intro Prog Src / HP.CC / HP.CC.txt < prev    next >
Encoding:
Text File  |  1987-09-05  |  8.8 KB  |  269 lines

  1. /*********************************************************************
  2. *                                                                    *
  3. *  HodgePodge                                                        *
  4. *  'C' version                                                       *
  5. *                                                                    *
  6. *  July 17, 1987                     vB2.0                           *
  7. *                                                                    *
  8. *     (c) Copyright 1986, 1987 Apple Computer, Inc.                  *
  9. *                                                                    *
  10. *     All rights reserved.                                           *
  11. *                                                                    *
  12. *     This program and its derivatives are licensed only for         *
  13. *     use on Apple computers.                                        *
  14. *                                                                    *
  15. *     Works based on this program must contain and                   *
  16. *     conspicuously display this notice.                             *
  17. *                                                                    *
  18. *     This software is provided for your evaluation and to           *
  19. *     assist you in developing software for the Apple IIGS           *
  20. *     computer.                                                      *
  21. *                                                                    *
  22. *     This is not a distribution license. Distribution of            *
  23. *     this and other Apple software requires a separate              *
  24. *     license. Contact the Software Licensing Department of          *
  25. *     Apple Computer, Inc. for details.                              *
  26. *                                                                    *
  27. *     DISCLAIMER OF WARRANTY                                         *
  28. *                                                                    *
  29. *     THE SOFTWARE IS PROVIDED "AS IS" WITHOUT                       *
  30. *     WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,               *
  31. *     WITH RESPECT TO ITS MERCHANTABILITY OR ITS FITNESS             *
  32. *     FOR ANY PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO             *
  33. *     THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH            *
  34. *     YOU.  SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU (AND            *
  35. *     NOT APPLE OR AN APPLE AUTHORIZED REPRESENTATIVE)               *
  36. *     ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING,             *
  37. *     REPAIR OR CORRECTION.                                          *
  38. *                                                                    *
  39. *     Apple does not warrant that the functions                      *
  40. *     contained in the Software will meet your requirements          *
  41. *     or that the operation of the Software will be                  *
  42. *     uninterrupted or error free or that defects in the             *
  43. *     Software will be corrected.                                    *
  44. *                                                                    *
  45. *     SOME STATES DO NOT ALLOW THE EXCLUSION                         *
  46. *     OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSION MAY              *
  47. *     NOT APPLY TO YOU.  THIS WARRANTY GIVES YOU SPECIFIC            *
  48. *     LEGAL RIGHTS AND YOU MAY ALSO HAVE OTHER RIGHTS                *
  49. *     WHICH VARY FROM STATE TO STATE.                                *
  50. *                                                                    *
  51. *********************************************************************/
  52.  
  53. #include <types.h>     
  54. #include <prodos.h>                             
  55. #include <misctool.h>                            
  56. #include <quickdraw.h>                         
  57. #include <qdaux.h>
  58. #include <window.h>
  59. #include <memory.h>
  60. #include <dialog.h>
  61. #include <menu.h>
  62. #include <control.h>
  63. #include <desk.h>
  64. #include <event.h>
  65. #include <lineedit.h>
  66. #include <misctool.h>
  67. #include <locator.h>
  68. #include <stdfile.h>
  69. #include <print.h>
  70. #include <font.h>
  71. #include <intmath.h>
  72. #include <list.h>
  73. #include <scrap.h>
  74. #include "hp.h"                               
  75.  
  76. extern int _toolErr;
  77.  
  78. boolean ToolsFound     = FALSE,                /* Do we have tools ? */
  79.         AllOk          = FALSE,
  80.         PManagerFound  = TRUE;                 /* assume the PM is there */
  81.  
  82. int MyID;
  83. int ThisMode = 0x80;                           /* init mode = 640 */
  84.  
  85. int ToolTable [] = {14,               /* Number of items */
  86.                    4,  0x100,         /* QuickDraw II */
  87.                    5,  0x100,         /* Desk Manager */
  88.                    6,  0x100,         /* Event Manager */
  89.                    14, 0x100,         /* Window Manager */
  90.                    15, 0x100,         /* Menu Manager */
  91.                    16, 0x100,         /* Control Manager */
  92.                    18, 0x100,         /* QuickDraw Auxiliary */
  93.                    19, 0x000,         /* Print Manager */
  94.                    20, 0x100,         /* Line Edit */
  95.                    21, 0x100,         /* Dialog Manager */
  96.                    22, 0x100,         /* Scrap Manager */
  97.                    23, 0x100,         /* Standard File  */
  98.                    27, 0x100,         /* Font Manager */
  99.                    28, 0x000};        /* List Manager */
  100.  
  101.  
  102.  
  103. char **y,*z;
  104.  
  105.  
  106. GrafPortPtr OrigPort;
  107.  
  108.  
  109.  
  110.  
  111.  
  112. /* This is the routine that will do the initialization of tools, will allocate
  113.    memory and all related tasks
  114. */
  115.  
  116.  
  117.  
  118. boolean StartUpTools ()
  119.  
  120. {
  121.    static char     SysToolsDirStr [] = "\p*/SYSTEM/TOOLS";
  122.    static FileRec  ParamBlock = { SysToolsDirStr , NULL };
  123.  
  124.    TLStartUp ();                               /* for calling tools */
  125.    CheckToolError (1);
  126.  
  127.    MyID = MMStartUp();                         /* ID for all transactions */
  128.    CheckToolError (2);
  129.  
  130.    MTStartUp();                                /* Misc. Tools  */
  131.    CheckToolError (3);                         /* Make sure all is OK      */
  132.  
  133.    y = NewHandle (0xA00L,                       /* Ten pages            */
  134.                   MyID,                         /* put it to my name    */
  135.                    attrBank +
  136.                    attrPage +
  137.                    attrFixed +
  138.                    attrLocked,
  139.                   0L);                          /* don't care           */
  140.    CheckToolError (4);
  141.  
  142.    z = *y;                                     /* deref handle     */
  143.  
  144.    QDStartUp ((int) z,ThisMode,MAXSCAN,MyID);
  145.    CheckToolError (5);
  146.  
  147.    EMStartUp((int) z + 0x300,20,0,640,0,200,MyID);  /* Event Manager */
  148.    CheckToolError (6);
  149.  
  150.    MoveTo       (20,20);
  151.    SetBackColor (0);
  152.    SetForeColor (15);
  153.    DrawString   ("\pOne Moment Please... ");
  154.    ShowCursor   ();
  155.  
  156. TryAgain:
  157.    GET_FILE_INFO (&ParamBlock);
  158.    if (_toolErr)
  159.        if (MountBootDisk () == 1)
  160.            goto TryAgain;
  161.        else
  162.            return (false);             /* Exit function unsuccessfully */
  163.  
  164.    LoadTools (ToolTable);              /* Now it's ok to do this */
  165.    CheckToolError (7);
  166.  
  167.    QDAuxStartUp ();
  168.    CheckToolError (8);
  169.  
  170.    WaitCursor ();                      /* Show wristwatch cursor */
  171.  
  172.    WindStartUp (MyID);
  173.    CheckToolError (9);
  174.  
  175.    RefreshDesktop (NULL);
  176.  
  177.    CtlStartUp (MyID,(int) z + 0x400);
  178.    CheckToolError (10);
  179.  
  180.    LEStartUp (MyID, (int) z + 0x500);
  181.    CheckToolError (11);
  182.  
  183.    DialogStartUp (MyID);
  184.    CheckToolError (12);
  185.  
  186.    MenuStartUp (MyID, (int) z + 0x600);
  187.    CheckToolError (13);
  188.  
  189.    DeskStartUp();                             /* All we need is init'ed now */
  190.    CheckToolError (14);
  191.  
  192.    ShowPleaseWait ();
  193.  
  194.    SFStartUp(MyID, (int) z + 0x700);
  195.    CheckToolError (15);
  196.    SFAllCaps (true);
  197.  
  198.    FMStartUp(MyID, (int) z + 0x800);           /* the watch cursor is up */
  199.    CheckToolError (16);                        /* while we count the fonts */
  200.  
  201.    ListStartup ();        /* >!< Note, not ListStartUp with upper case "U"! */
  202.    CheckToolError (17);
  203.  
  204.    PMStartUp (MyID, (int) z + 0x900);
  205.    CheckToolError (18);
  206.  
  207.    ScrapStartUp ();
  208.    CheckToolError (19);
  209.  
  210.    HidePleaseWait ();      /* Remove dialog box */
  211.    InitCursor ();          /* Show arrow cursor */
  212.  
  213.    return (true);          /* Exit function successfully */
  214. }
  215.  
  216.  
  217.  
  218.  
  219.  
  220. ShutDownTools ()
  221.  
  222. {
  223.    DeskShutDown ();
  224.  
  225.    if (WindStatus () != 0)
  226.        HideAllWindows ();
  227.  
  228.    ListShutDown   ();
  229.    FMShutDown     ();
  230.    ScrapShutDown  ();
  231.    PMShutDown     ();
  232.    SFShutDown     ();
  233.    MenuShutDown   ();
  234.    DialogShutDown ();
  235.    LEShutDown     ();
  236.    CtlShutDown    ();
  237.    WindShutDown   ();
  238.    EMShutDown     ();
  239.  
  240.    if (QDStatus () != 0)
  241.        GrafOff ();
  242.  
  243.    QDShutDown ();
  244.    MTShutDown ();
  245.  
  246.    if (MMStatus () != 0)
  247.    {
  248.        DisposeHandle (y);
  249.        MMShutDown    (MyID);
  250.    }
  251.    TLShutDown ();
  252. }
  253.  
  254.  
  255.  
  256.  
  257.  
  258. /* MAIN program routine */
  259.  
  260. main ()
  261. {
  262.    if (StartUpTools ())                /* Try to initialize tools           */
  263.    {
  264.        SetUpMenus ();
  265.        MainEvent  ();
  266.    }
  267.    ShutDownTools ();                   /* Shutdown tools even if didn't run */
  268. }
  269.